package lab01;

/**
 * Created by Administrator on 2017/12/17.
 */
public class Test05_3 {
    public static void main(String[] args) {
        int n=100;
        System.out.println(sum1(n));
        System.out.println(sum2(n));
        System.out.println(sum3(n));
    }
    public static int sum1(int n){
        int sum=0;
        for (int i=1;i<=n;i++){
            sum=sum+i;
        }return sum;
    }
    public static int sum2(int n){
        int sum=0,i=1;
        while (i<=n){
            sum=sum+i;
            i++;
        }return sum;
    }
    public static int sum3(int n){
        int sum=0,i=1;
        do {
            sum=sum+i;
            i++;
        }while (i<=n);
        return sum;
    }
}
